import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { toJS } from 'mobx';
import { inject, observer } from "@tarojs/mobx-rn";
import { View, Image, Text } from "@tarojs/components-rn";
import { getRuntime } from "../../utils/common";
import lifeStyleSheet from "./life_styles";
var _styleSheet = lifeStyleSheet;
let Personnel = class Personnel extends Component {
  constructor(props) {
    super(props);
    this.state = {
      items: []
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '生活服务中心' });
    this.getAllLifeService();
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  getAllLifeService() {
    let { LifeServiceStore } = this.props.stores;
    LifeServiceStore.getAllLifeService({
      callBack: res => {
        this.setState({
          items: toJS(res.items)
        });
      }
    });
  }
  link(url) {
    if (url && url.includes('http')) {
      window.location.href = url;
    } else {
      getRuntime().navigateTo(url);
    }
  }
  render() {
    let { items } = this.state;
    return <View style={_styleSheet["all-life"]}>
        {items.length > 0 && items.map(item => {
        return <View key={item.id}>
                <View style={_styleSheet["type"]}>{item.lifeServiceCateGoryName}</View>
                <View style={_styleSheet["index-nav"]}>
                  {item.lifeServicesVO && item.lifeServicesVO.map(nav => {
              return <View key={item.id + '_' + nav.id} onClick={this.link.bind(this, nav.url)} style={_styleSheet["nav"]}>
                          <Image src={nav.logoIMG} style={_styleSheet["nav-icon"]} />
                          <Text style={_styleSheet["nav-title"]}>{nav.name}</Text>
                        </View>;
            })}
                  {item.lifeServicesVO.length <= 0 && <View style={_styleSheet["page-none-info"]}>暂无相关应用~</View>}
                </View>
                <View style={_styleSheet["interval"]} />
              </View>;
      })}
        {items.length <= 0 && <View style={[_styleSheet["page-none-info"], _styleSheet["page-none-info-center"]]}>暂无相关服务应用，敬请期待...</View>}
      </View>;
  }
};
Personnel = tslib_1.__decorate([inject("stores"), observer], Personnel);
export default Personnel;